/**
 * @file       AppEventListener.h
 * @brief      The  class for event listeners that dispatch the application event
 * @author     Huabo Zheng
 * @date       Jan 13, 2012
 * @Copyright  2012, www.netgear.com Inc. All rights reserved.
 */


#ifndef APPEVENTLISTENER_H_
#define APPEVENTLISTENER_H_

#include "IEventListener.h"

namespace NS_LCD_AFW
{

/**
 *@class  CAppEventListener
 *@brief  The  class for event listeners that dispatch the application event
 */
class CAppEventListener: public NS_LCD_AFW::IEventListener
{
public:
	/**
	 *@brief Constructor
	 *@attention This objects can only be create in the heap memory and call destroy() for destruction
	 *@see destory
	 */
	CAppEventListener();

	/**
	 *@brief Constructor
	 *@details Constructor
	 *@param[in]  pEventHandler A pointer to a CEventHandler object that responsible for handling events
	 *@param[in]  bAutoRelease Indicate that the object is freed by the caller or by the Callee
	 *@note
	 *@attention This objects can only be create in the heap memory and call destroy() for destruction
	 *@see destory
	*/
	CAppEventListener(CEventHandler *pEventHandler, bool bAutoRelease = true);

	/**
	 *@brief Constructor
	 *@details Constructor
	 *@param[in]  pEventHandler A pointer to a CEventHandler object that responsible for handling events
	 *@param[in] eventId Specify the event ID that the listener interested in
	 *@param[in] callBack when the interesting event occurs,the listener will call the callBack function to process
	 *@param[in] param Specify the param that pass to the callBack function when event occurs
	 *@param[in]  bAutoRelease Indicate that the object is freed by the caller or by the Callee
	 *@note
	 *@attention This objects can only be create in the heap memory and call destroy() for destruction
	 *@see destory
	*/
	CAppEventListener(CEventHandler *pEventHandler, int interestEventId,AFW_EventCallBack callBack, int param = INVALID_PARAM,bool bAutoRelease = true);

public:

	/**
	 *@brief Event dispatcher
	 *@details Dispatch event to the handler or callback function
	 *@param[in] pEvent A pointer to a CAppEvent object
	 *@exception none
	 *@retval    int
	 *@return    ERR_SUCCESS if success,ERR_NOT_APP_EVENT if the input param is not the type of CAppEvent, otherwise failure
	 *@note
	 *@attention
	 *@see
	 */
	virtual int actionPerformed(IEvent *pEvent);
protected:
	/**
	*@brief DeConstructor
	*@attention This objects can only be create in the heap memory and call destroy() for destruction
	*@see destory()
	*/
	virtual ~CAppEventListener();

private:
	DISABLE_COPY_CONSTRUCTOR_AND_ASSIGN_REFERENCE(CAppEventListener);

};

} /* namespace NS_LCD_AFW */
#endif /* APPEVENTLISTENER_H_ */
